*Master

*set directory
cd SET TO ROOT DIRECTORY

*generate macro data
do "./scripts/gd_Macrodata.do"

*Gen micro data
do "./scripts/gd_Microdata.do"

*Merge
use "./gendata/macrodata.dta", clear
merge 1:m cntry using "./gendata/microdata.dta"
drop _mer
order id cname cntry counnum
keep if native2==1
drop native*
*drop if ifriends>=.

compress
xtset id
save "./gendata/maindata",replace

*Analysis
do "./scripts/ana_main.do"

exit
